#ifndef DATASET_H
#define DATASET_H

#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>

#include <boost/shared_ptr.hpp>

using namespace std;

/**
 * In this namespaces all apriori-test-classes are included.
 * \author Michael Opitz
 * \version 0.1
 */
namespace apriori_test {
	/**
	 * This class is a example of a dataset, which is read from a file
	 * with the file_reader class (operator >>), and implements the 
	 * get_elements method, which is neccessary for the apriori algorithm.
	 * moreover it defines the neccessary types, and its elements are 
	 * implementing the ==-operator, to work with the apriori-algorithm
	 */
	class dataset {
	public:
		typedef boost::shared_ptr<dataset> ptr;

		typedef string data;
		typedef boost::shared_ptr<string> data_ptr;

		typedef vector<string> data_collection;
		typedef vector<boost::shared_ptr<string> > data_coll;

		dataset() {}
		~dataset() {}

		template <class T>
		void read(T &rhs)
		{
			string tmp;
			string tmp2;
			getline(rhs, tmp);
			stringstream stream(tmp);

			while(!stream.eof()) {
				stream >> tmp2;
				_line.push_back(boost::shared_ptr<string>(
					new string(tmp2)));
			}
		}

		template <class T>
		void write(T &rhs)
		{
			for(int i = 0; i < int(_line.size()); ++i) {
				rhs << *_line[i] << " ";
			}
		}

		data_coll& get_elements() { return _line; }

		const data_coll& get_line() const { return _line; }
		void set_line(const data_coll &l) { _line = l; }
	private:
		vector<boost::shared_ptr<string> > _line;
	};
}

ifstream& operator >> (ifstream &rhs, apriori_test::dataset &set);
stringstream& operator >> (stringstream &rhs, apriori_test::dataset &set);
istream& operator >> (istream &rhs, apriori_test::dataset &set);

ofstream& operator << (ofstream &rhs, apriori_test::dataset &set);
stringstream& operator << (stringstream &rhs, apriori_test::dataset &set);
ostream& operator << (ostream &rhs, apriori_test::dataset &set);


#endif
